<%@page import="cn.ticket.Constant"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="cn.ticket.db.DBConnect"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加车次</title>
</head>
<body>
	<jsp:include page="../common/head.jsp"></jsp:include>
	<%
	String userId= (String)session.getAttribute("login_user_id") ;
	String busId = (String)request.getParameter("id") ;
	Connection con =  new DBConnect().getConnection()  ;
	String sql = "select * from bus where id =? " ;
	PreparedStatement pstmt = con.prepareStatement(sql) ;
	pstmt.setString(1,busId) ;
	
	ResultSet rs = pstmt.executeQuery() ;
	if(rs.next()){
		String oriStation1= rs.getString(3).split("-")[0] ;
		String oriStation2= rs.getString(3).split("-")[1] ;
		String desStation1= rs.getString(4).split("-")[0] ;
		String desStation2=rs.getString(4).split("-")[1] ;
		%>
	<div class="content">
		<jsp:include page="../common/bar_left.jsp"></jsp:include>
				<div class="row">
				<div class="form">
			<form class="form-horizontal w550" role="form" action="<%=basePath%>front/bus/busUpdate_handle.jsp" method="post">
			
			<input type="hidden" id="oriStation01" value="<%=oriStation1 %>" />
			<input type="hidden" id="oriStation02" value="<%=oriStation2 %>" />
			<input type="hidden" id="desStation01" value="<%=desStation1 %>" />
			<input type="hidden" id="desStation02" value="<%=desStation2 %>" />
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">汽车车次</label>
					<div class="col-sm-10">
						<input type="hidden" name="id" value="<%=rs.getString(1)%>" />
						<input type="text" name="num" class="form-control" value="<%=rs.getString(2)%>" id="inputEmail3" placeholder="车次">
					</div>
				</div>
				<div class="form-group">
					<label for="inputName3" class="col-sm-2 control-label">出发站</label>
					<div class="col-sm-10">
							<select name="oriStation1" class="form-control w150" id="oriStation1"><span style="color: red;">*</span></select> 
							<select name="oriStation2" class="form-control w150" id="oriStation2"><option value="">选择城市</option>	</select>
					</div>
				</div>
				<div class="form-group">
					<label for="inputName3" class="col-sm-2 control-label">终点站</label>
					<div class="col-sm-10">
						<select name="desStation1" class="form-control w150" id="desStation1"><span style="color: red;">*</span></select> 
						<select name="desStation2" class="form-control w150" id="desStation2"><option value="">选择城市</option></select>
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">出发时间</label>
					<div class="col-sm-10">
						<input type="text" name="time" class="form-control" value="<%=rs.getString(6)%>" 
						placeholder="出发时间"/>
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">价格</label>
					<div class="col-sm-10">
						<input type="text" name="price" class="form-control" value="<%=rs.getString(5)%>" 
						id="inputPassword3" placeholder="价格">
					</div>
				</div>
				
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">总座位数</label>
					<div class="col-sm-10">
						<input type="text" name="total" class="form-control" value="<%=rs.getString(8)%>" 
						placeholder="出发时间"/>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="submit" class="btn btn-default">提　交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	</div>
	<%
	}else{
		session.setAttribute("errorinfo", Constant.ERRORINFO_NETERROR) ;
		%>
			<jsp:forward page="../result.jsp"/>
		<%
	}
	%>
	<jsp:include page="../common/footer.jsp"></jsp:include>
	<script type="text/javascript" src="<%=basePath%>js/map/map_data.js" ></script>
	<script type="text/javascript" src="<%=basePath%>js/map/map_js.js"></script>
	<script type="text/javascript">
	$(document).ready(function(){
		//初始化省市
		init("oriStation1",$('#oriStation01').val(),"oriStation2",$('#oriStation02').val(),"hometown","");
		init("desStation1",$('#desStation01').val(),"desStation2",$('#desStation02').val(),"hometown","");
		
// 		setTimeout(function(){
// 			$('#oriStation1').val()
// 		})
	})
	</script>
</body>
</html>